import push from '../../nopack/cheways-push.js'
import mainTabs from '../../nopack/main-tabs.js'

localStorage.templateInfo = JSON.stringify({
})

window.vm = new Vue({
	el: '#main',
	data: {
		curTab: 0,
		title: '首页',
		tabbar: [{
			icon: 'icon-home-normal',
			iconActive: 'icon-home-press',
			title: '首页',
			url: './home.html',
			noNavi: true,
		}, {
			icon: 'icon-More-normal',
			iconActive: 'icon-More-press',
			title: '更多',
			url: './service.html'
		}, {
			icon: 'icon-Username',
			iconActive: 'icon-Username-press',
			title: '我的',
			url: './mine.html',
			noNavi: true,
		}],
	},
	ready: function() {
		var vm = this;
		mui('header')[0].style.marginTop = localStorage.immersed + 'px';
		mui.init();
		if(mui.os.plus) {
			mui.plusReady(function() {
				push.init();
				mainTabs.plusInit(vm.tabbar)
			});
		} else {
			mainTabs.init(vm.tabbar)
		}
		localStorage.setItem("showBindMessage",false);
		this.getCarBinding();
	},
	methods: {
		tab: function(index) {
			this.curTab = index;
			// 标题切换
			this.title = this.tabbar[index].title;
			mainTabs.tab(index);
		},
		getCarBinding: function() {
			var vm = this;
			app.ajax({
				url: app.api.getHomePromt,
				data: {
					cname: JSON.parse(localStorage.lastLogin).name,
				},
				success: function(d, message) {
					if (d==1) {
						localStorage.setItem("showBindMessage",true);
					}
				}
			})
		},
	}
})